package com.example.testcomposeproject.pages.testEt

import com.ioidea.base.mvvm.MvvmBaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject


/**
 * @author: hemin
 * @date: 2024/9/9
 * @Desc:
 */
@HiltViewModel
class TestEtViewModel @Inject constructor(
    private val model: TestEtModel,
) : MvvmBaseViewModel<TestEtContract.Event, TestEtContract.State>() {



    private fun lampTest() {
    }




    override fun createInitialState(): TestEtContract.State =
        TestEtContract.State()

    override fun handleEvents(event: TestEtContract.Event) {
        when (event) {
            is TestEtContract.Event.DevTest -> {
                lampTest()
            }
            is TestEtContract.Event.HideLoadingDialog ->hideLoading()
            is TestEtContract.Event.ShowLoadingDialog ->  showLoading()
        }
    }

    val list= listOf("1","2","3")
    fun onEtLamppostValueChange(it: String?) {
        setState { copy(lamppostTypeName = it?:"") }
        for (s in list) {
            if (s==it){
                setState { copy(lamppostAlreadyExist = true) }
                return
            }
        }
        setState { copy(lamppostAlreadyExist = false) }
    }

}